package com.dawn.usermanage.dao;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.dawn.interestmanage.bean.InterestinfoBean;
import com.dawn.interestmanage.bean.UserinterestBean;
import com.dawn.usermanage.bean.UserBean;

@Repository
public class UserManageDao {

    @Autowired
    private HibernateTemplate hibernateTemplate;

    public List<UserBean> findUserByUid(int userId){
        @SuppressWarnings("unchecked")
        List<UserBean> users = (List<UserBean>) hibernateTemplate.find("from UserBean u where u.userId = ?", userId);
        return users;
    }
    
    public List<UserBean> findUserByUName(String userName) {
        @SuppressWarnings("unchecked")
        List<UserBean> users = (List<UserBean>) hibernateTemplate.find("from UserBean u where u.userName = ?", userName);
        return users;
    }
    
    public List<UserBean> findUserBySId(String sinaId) {
        @SuppressWarnings("unchecked")
        List<UserBean> users = (List<UserBean>) hibernateTemplate.find("from UserBean u where u.twSinainfo.sinaId = ?", sinaId);
        return users;
    }

   /* public List<InterestinfoBean> findInterByUserId(int userId){
        @SuppressWarnings("unchecked")
        List<UserinterestBean> interests = (List<UserinterestBean>) hibernateTemplate.find("from UserinterestBean ui where ui.userId = ?", userId);
        List<InterestinfoBean> interestnames = null;
        InterestinfoBean ib=new InterestinfoBean();
        for(int i=0;i<interests.size();i++)
        {
        	ib=(InterestinfoBean)hibernateTemplate.find("from InterestinfoBean i where i.interestId = ?", interests.get(i).getInterestId());
        	interestnames.add(ib);
        }
      
        
        return interestnames;
    }*/
}
